from django.forms import ModelForm

from xadmin.models import ArticleGroup


class ArticleGroupForm(ModelForm):
    class Meta:
        model = ArticleGroup
        exclude = ('site', 'article')

    def __init__(self, *args, **kwargs):
        super(ArticleGroupForm, self).__init__(*args, **kwargs)
        for field_name in self.fields:
            field = self.fields[field_name]
            if field_name != 'content':
                field.widget.attrs.update({'class': 'form-control'})